package com.frinder.seata.data.base;

import lombok.Getter;

/**
 * @ClassName CODE
 * @Description
 * @Author frinder
 * @Date 2020/4/24 18:11
 * @Verion 1.0
 */
public enum CODE {
    SUCCESS(200, "成功！"),
    PART_SUCCESS(201, "部分成功"),
    FAIL(400, "失败！"),
    SYSTEM_ERROR(10000, "系统错误！"),
    DB_MORE_THAN_ONE(20001, "只应有一个查询结果！"),
    DB_SAVE_FAIL(20001, "保存失败！"),
    DB_UPDATE_FAIL(20003, "更新失败！"),
    DB_DELETE_FAIL(20004, "删除失败！"),
    EXPECT_RECORD_NOT_EXISTS(30001, "期望记录不存在！"),
    CALL_SERVICE_ERROR(40001, "调用第三方服务失败！"),
    TIME_OUT(50001, "连接超时！"),
    ;

    @Getter
    private int code;
    @Getter
    private String message;

    CODE(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public boolean success() {
        return SUCCESS.code == this.code;
    }

    public boolean fail() {
        return FAIL.code == this.code;
    }
}
